package com.shuoyue.ycgk.ui.estimate;

import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.entity.Estimate;
import com.shuoyue.ycgk.entity.EstimateHis;
import com.shuoyue.ycgk.entity.UserTestPaper;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import java.util.List;

import io.reactivex.Observable;

public interface EstimateHisContract {
    interface View extends BaseView {
        void getEsListHisSuc(List<EstimateHis> list);

    }

    class Presenter extends BasePresenter<View> {
        Model model = new Model();

        public void getEsListHis(int moduleId) {
            apply(model.getEsListHis(  moduleId))
                    .subscribe(new ApiSubscriber<Optional<List<EstimateHis>>>(mView, this) {
                        @Override
                        public void onNext(Optional<List<EstimateHis>> listWithPageOptional) {
                            super.onNext(listWithPageOptional);
                            mView.getEsListHisSuc(listWithPageOptional.getIncludeNull());
                        }
                    });
        }

    }

    class Model {
        Observable<BaseResult<List<EstimateHis>>> getEsListHis(int moduleId) {
            return RetrofitClient.getInstance().getApi().getEsListHis(  moduleId);
        }

    }
}
